/*
    Project:        Home Power Control
    File:           HPCRequest.h
    Author:         christian@karunamusic.at
    Date:           02.2015
    Description:    Requests for the client/server communication.
 */

#ifndef HPCREQUEST_H
#define HPCREQUEST_H

#include <QDataStream>
#include <QByteArray>

typedef enum
{
    undefined = 0,
    config,
    valueChanged,
    valueAlarmed
} TRequestType;

class HPCRequest : public QByteArray
{
public:
    /** \brief Constructor.
     * Construct the object as Request.
     *
     * \param rt Requesttype (see enum TRequestType).
     */
    HPCRequest( TRequestType rt );
    /** \brief Constructor.
     * Construct the object as Answer.
     *
     * \param ref QByteArray from the socket.
     */
    HPCRequest( QByteArray& ref );
    virtual ~HPCRequest();

    inline QDataStream& Stream()
        { return *m_Stream; }

    inline TRequestType Type() const
        { return m_Type; }

private:
    void setup();

    QDataStream* m_Stream;
    TRequestType m_Type;
    bool m_Request;
};

#endif // HPCREQUEST_H
